<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
</head>
<style>
    .img-responsive {
        display: block;
        max-width: 100% !important;
        height: auto !important;
    }
    .adminex-form .col-sm-9{
        padding-right: 30px;
        padding-left: 0;
    }
</style>
<body>
{include file='public/header'/}
<section>
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是:</li>
                <li><a href="javascript:history.back();">商户管理</a></li>
                <li><a href="javascript:history.back();">商户列表</a></li>
                <li class="active" style="color: #02b87f;">门店详情</li>
            </ul>
        </div>
        <div class="mgl15 mgr15">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 style="margin:0;font-size:16px;color:#02b87f;">门店名称&nbsp;:&nbsp;<span>{$user.merchant}</span>
                    </h4>
                </div>
            </div>
            <ul id="myTab" class="nav nav-tabs mgb10">
                <li class="active">
                    <a class="fsz14" href="#Message" data-toggle="tab">基础信息</a>
                </li>
                <li>
                    <a class="fsz14" href="#Cashier" data-toggle="tab">人员列表</a>
                </li>
                <li>
                    <a class="fsz14" href="#Facility" data-toggle="tab">设备列表</a>
                </li>

                <li>
                    <a class="fsz14" href="#Journal" data-toggle="tab">操作日志</a>
                </li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="Message">
                    {if condition="checkPath('mach/machxg')"}
                        <div class="col-sm-12 text-right">
                            <a href='{:url("mach/machxg")}?id={$user.id}' class="btn btn-info">修改</a>
                        </div>
                    {/if}
                    <table class="table table-bordered">
                        <caption>基础信息</caption>
                        <tbody>
                        <tr>
                            <td class="active">营业状态</td>
                            <td>{:getmachstatu($user['status'])}</td>
                            <td class="active">创建时间</td>
                            <td>{$user['addtime']|date="Y-m-d H:i:s",###}</td>
                            <td class="active">门店类别</td>
                            <td>{:getlevel($user['leibie'])}</td>
                        </tr>
                        </tbody>
                    </table>
                    <table class="table table-bordered">
                        <caption>代理商信息</caption>
                        <tbody>
                        <tr>
                            <td class="active">业务员</td>
                            <td>{:getsales($user['salesman'])}</td>
                            <td class="active">代理商名称</td>
                            <td>{:getagent($user['agent'],"name")}</td>
                            <td class="active">代理商账户</td>
                            <td>{:getagent($user['agent'],"zh")}</td>
                        </tr>
                        </tbody>
                    </table>
                    <table class="table table-bordered">
                        <caption>商户信息</caption>
                        <tbody>
                        <tr>
                            <td class="active">微信商户号</td>
                            <td colspan="2">{$user['sub_mch_id']}</td>
                            <td class="active">支付宝Token</td>
                            <td colspan="2">{$user['ali_merid']}</td>
                        </tr>
                        <tr>
                            <td class="active">商户联系人</td>
                            <td>{$user['MerchantContent']['contacts']}</td>
                            <td class="active">联系方式</td>
                            <td>{$user['MerchantContent']['tel']}</td>
                            <td class="active">地址</td>
                            <td>{$user['MerchantContent']['address']}</td>
                        </tr>
                        </tbody>
                    </table>
                    {if condition="checkPath('mach/open_auth')"}
                    <table class="table table-bordered">
                        <caption>微信公众号授权</caption>
                        <tbody>
                        <tr>

                            <td class="active">授权情况</td>
                            <td>{if condition="$user['auth_type'] eq 0"}继承上级商户公众号{else /}自有公众号{/if}：<font color="green"> {$wxopen['gh_nick_name']}</font></td>

                            <td class="active">Appid</td>
                            <td>{$wxopen['authorizer_appid']}</td>

                            <td class="active">原始ID</td>
                            <td>{$wxopen['gh_id']}</td>
                        </tr>
                        <tr>
                            <td class="active">公众号认证信息</td>
                            <td>{:getwxlx($wxopen['verify_type_info'])}{:getwxrz($wxopen['service_type_info'])}</td>
                            <td class="active">认证主体</td>
                            <td>{$wxopen['principal_name']}</td>
                            <td class="active">授权时间</td>
                            <td>{:date('Y-m-d H:i:s',$wxopen['addtime'])}</td>

                        </tr>
                       <tr>
                           <td class="active">重新授权</td>
                           <td colspan="6"><a href="{:url('mach/open_auth')}?id={$user['id']}"><img style="width:100%;height:100%;" src="https://open.weixin.qq.com/zh_CN/htmledition/res/assets/res-design-download/icon_button3_1.png"/></a>

                           </td>
                       </tr>

                        </tbody>
                    </table>
                    <div class="alert alert-danger">授权公众号前请确认您的公众号为认证服务号，且已开通模版消息功能，子门店授权完成后不再继承母商户公众号</div>
                    {/if}
                </div>
                <!--员工列表-->
                <div class="tab-pane fade" id="Cashier">
                    {if condition="checkPath('personnel/cashieradd')"}
                        <div class="col-sm-12 text-right mgb10">
                            <a href="{:url('personnel/cashieradd')}" class="btn btn-info">添加收银员 </a>
                        </div>
                    {/if}
                    <table class="table table-bordered">
                        <thead>
                            <tr class="active">
                                <th>工号</th>
                                <th>姓名</th>
                                <th>手机号</th>
                                <th>员工角色</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {volist name="cashier" id="vo"}
                            <tr>
                                <td class="mid">{$vo.gonghao}</td>
                                <td class="mid">{$vo.xingming}</td>
                                <td class="mid">{$vo.tel}</td>
                                <td class="mid">{:getuserlevel($vo['level'])}</td>
                                <td class="mid">
                                    {if condition="checkPath('personnel/cashierdel')"}
                                    <a href="javascript:;" data-id="{$vo.id}" data-uid="{$vo.uid}" class="cashierdel btn-link">删除</a>
                                    {/if}
                                    {if condition="checkPath('personnel/cashieredit')"}
                                    <a class="btn-link" href="{:url('Personnel/cashieredit',['id'=>$vo['uid']])}">&nbsp;|&nbsp;&nbsp;详情</a>
                                    {/if}
                                </td>
                            </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <!--设备列表-->
                <div class="tab-pane fade" id="Facility">
                    {if condition="checkPath('mach/addprint')"}
                    <div class="col-sm-12 text-right mgb10">
                        <button data-toggle="modal" data-target="#myModal2" type="button" name="Facility" method="post" action="" class="btn btn-info">添加设备
                        </button>
                    </div>
                    {/if}
                    <table class="table table-bordered">
                        <thead>
                        <tr class="active">
                            <th>设备类型</th>
                            <th>设备名称</th>
                            <th>设备SN</th>
                            <th>添加日期</th>
                            <th>添加人</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {if condition="checkPath('mach/listprint')"}
                        {volist name="print" id="vo"}
                        <tr>
                            <td class="mid">{$vo.leixing}</td>
                            <td class="mid">{$vo.sbname}</td>
                            <td class="mid">{$vo.sn}</td>
                            <td class="mid">{$vo['addtime']|date="Y-m-d H:i:s",###}</td>
                            <td class="mid">{$vo.adduser}</td>
                            <td class="mid">
                                {if condition="checkPath('mach/delprint')"}
                                <a href="javascript:;" class="printdel btn-link" data-id="{$vo.id}">移除</a>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                        {/if}
                        </tbody>
                    </table>
                </div>
                <!--操作日志-->
                <div class="tab-pane fade" id="Journal">
                    <table class="table table-bordered">
                        <thead>
                        <tr class="active">
                            <th>日志编号</th>
                            <th>操作人</th>
                            <th>操作类型</th>
                            <th>操作时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="czlog" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
                            <td>{$vo.username}</td>
                            <td>{$vo.log}</td>
                            <td>{$vo['create_time']}</td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- 添加设备模态框（Modal） -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加设备
                </h4>
            </div>
            <div class="modal-body">
                <ul id="myTab" class="nav nav-tabs">
                    <li class="active">
                        <a href="#print" data-toggle="tab">
                            打印机
                        </a>
                    </li>
                </ul>
                <div id="myTabContent2" class="tab-content" style="margin-top: 15px;">
                    <div class="tab-pane fade in active" id="print">
                        <form id="frm" class="form-horizontal">
                            <input type="hidden" name="mid" value="{:request()->get('id')}" id="pmid">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">设备名称：</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id='sbname' name='sbname'>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">打印机用户名：</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id='usernames' name='username'>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">Ukey：</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id='ukey' name='ukey'>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">SN：</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id='sn' name='sn'>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="addprint()">添加</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="myModalDevice" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel3">
                    添加微端收银员
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal adminex-form" action="" method="post" id="cashieradd"
                      enctype="multipart/form-data">
                    <div class="form-group" id="ferror5">
                        <label class="col-sm-2 col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="xingming" name="xingming">
                            <div id="error5" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror1">
                        <label class="col-sm-2 col-sm-2 control-label">登入账号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="username" name="username">
                            <div id="error1" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror2">
                        <label class="col-sm-2 col-sm-2 control-label">密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="password" name="password">
                            <div id="error2" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror4">
                        <label class="col-sm-2 col-sm-2 control-label">退款密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="tk_password" name="tk_password">
                            <div id="error3" class="error"></div>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" onclick="adddeviceuser()">
                    提交
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="myModalDevice_md" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel6">
                    修改微端收银员
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal adminex-form" action="" method="post" id=""
                      enctype="multipart/form-data">
                    <div class="form-group" id="ferror6">
                        <label class="col-sm-2 col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="id" id="id_md" value="">
                            <input type="text" class="form-control ipt4" id="xingming_md" name="xingming">
                            <div id="error6" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror7">
                        <label class="col-sm-2 col-sm-2 control-label">登入账号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="username_md" readonly="readonly"
                                   name="username">
                            <div id="error7" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror8">
                        <label class="col-sm-2 col-sm-2 control-label">密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="password_md" name="password">
                            <div id="error8" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror9">
                        <label class="col-sm-2 col-sm-2 control-label">退款密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control ipt4" id="tk_password_md" name="tk_password">
                            <div id="error9" class="error"></div>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" onclick="deviceuser_md()">
                    提交
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
<script type="text/javascript">
    <!--添加设备-->
    function addprint() {
        $.ajax({
            type: "POST",
            url: "{:url('mach/addprint')}",
            async: false,
            data: $('#frm').serialize(),
            success: function (data) {
                if(data.code==0){
                    layer.msg("添加成功",{icon:1});
                    $('#myModal2').modal('hide');
                    setTimeout("window.location.reload()",500);
                }else{
                    layer.alert(data.message);
                    return false;
                }
            }
        });
    }
    function adddeviceuser() {
        var mid = {$user['id']};
        var username = $('#myModalDevice #username').val();
        var password = $('#myModalDevice #password').val();
        var tk_password = $('#myModalDevice #tk_password').val();
        var xingming = $('#myModalDevice #xingming').val();
        if (xingming == '') {
            alert('姓名必填');
            return
        }
        if (username == '') {
            alert('登入账号必填');
            return
        }
        if (password == '') {
            alert('密码必填');
            return
        }
        $.ajax({
            type: 'post',
            url: "{:url('Mach/adddeviceuser')}",
            //dataType:"json",
            data: {
                merchid: mid,
                username: username,
                password: password,
                tk_password: tk_password,
                xingming: xingming,
            },
            success: function (data) {

                switch (data) {
                    case 0:
                        alert('添加成功');
                        window.location.reload();
                        break;
                    case 1:
                        alert('添加失败');
                        break;
                    case 2:
                        alert('用户已存在');
                        break;

                }


            }
        })
    }
    function deviceuser_modify(id, xingming, username) {
        $('#myModalDevice_md #id_md').val(id);
        $('#myModalDevice_md #xingming_md').val(xingming);
        $('#myModalDevice_md #username_md').val(username);

        $('#myModalDevice_md').modal('show');

    }
    function deviceuser_md() {
        var id = $('#myModalDevice_md #id_md').val();
        var password = $('#myModalDevice_md #password_md').val();
        var tk_password = $('#myModalDevice_md #tk_password_md').val();
        var xingming = $('#myModalDevice_md #xingming_md').val();
        if (xingming == '') {
            alert('姓名必填');
            return
        }
        $.ajax({
            type: 'post',
            url: "{:url('Mach/deviceuser_md')}",
            //dataType:"json",
            data: {
                id: id,
                password: password,
                tk_password: tk_password,
                xingming: xingming,
            },
            success: function (data) {

                switch (data) {
                    case 0:
                        alert('修改成功');
                        window.location.reload();
                        break;
                    case 1:
                        alert('修改失败');
                        break;
                    case 2:
                        alert('用户已存在');
                        break;

                }
            }
        })
    }
    $(function(){
        //        删除员工方法
        $(".cashierdel").click(function(event){
            event.stopPropagation();
            var id = $(this).attr("data-uid");
            //询问框
            layer.confirm('确认删除该员工吗？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.ajax({
                    url:"{:url('personnel/cashierdel')}",
                    type:"post",
                    async:true,
                    data:{
                        id:id
                    },
                    success:function(data){
                        if(data.code==0){
                            layer.msg("删除成功",{time: 500,icon: 1});
                            setTimeout("window.location.reload()",500);
                            return false;
                        }else{
                            layer.alert(data.message,{icon:7});
                            return false;
                        }
                    }
                })
            }, function(){});
        });
        //        删除设备方法
        $(".printdel").click(function(event){
            event.stopPropagation();
            var id = $(this).attr("data-id");
            //询问框
            layer.confirm('确认删除该设备吗？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.ajax({
                    url:"{:url('mach/delprint')}",
                    type:"post",
                    async:true,
                    data:{
                        id:id
                    },
                    success:function(data){
                        if(data.code==0){
                            layer.msg("删除成功",{time: 500,icon: 1});
                            setTimeout("window.location.reload()",500);
                            return false;
                        }else{
                            layer.alert(data.message,{icon:7});
                            return false;
                        }
                    }
                })
            }, function(){});
        });
    })
</script>

</html>